package com.info3k.client.commands;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.RootPanel;
import com.info3k.client.Info3K;
import com.info3k.client.commands.address.AddressCommand;
import com.info3k.client.commands.address.MyAddressCommand;
import com.info3k.client.commands.address.NewAddressCommand;
import com.info3k.client.commands.category.NewCategoryCommand;
import com.info3k.client.commands.event.EventCommand;
import com.info3k.client.commands.event.MyEventCommand;
import com.info3k.client.commands.event.NewEventCommand;
import com.info3k.client.commands.location.LocationCommand;
import com.info3k.client.commands.location.MyLocationCommand;
import com.info3k.client.commands.location.NewLocationCommand;

public class CommandHandler implements Command {
	private String type;
	
	private Info3K info3k;

	public CommandHandler(String type, Info3K info){
		this.info3k = info;
		this.type = type;
	}
	
	public void execute() {
		if(type.equals("locationList")){
			LocationCommand cmd = new LocationCommand(RootPanel.get("right_section"), info3k, null, null);
			cmd.execute();
		} else if(type.equals("addNewLocation")){
			NewLocationCommand cmd = new NewLocationCommand(info3k);
			cmd.execute();
		} else if(type.equals("addNewCategory")){
			NewCategoryCommand cmd = new NewCategoryCommand(info3k);
			cmd.execute();
		} else if(type.equals("addNewEvent")){
			NewEventCommand cmd = new NewEventCommand(info3k);
			cmd.execute();
		} else if(type.equals("addressList")){
			AddressCommand cmd = new AddressCommand(RootPanel.get("right_section"), info3k);
			cmd.execute();
		} else if(type.equals("addNewAddress")){
			NewAddressCommand cmd = new NewAddressCommand(info3k);
			cmd.execute();
		} else if(type.equals("myLocations")){
			MyLocationCommand cmd = new MyLocationCommand(RootPanel.get("right_section"), info3k);
			cmd.execute();
		} else if(type.equals("myAddresses")){
			MyAddressCommand cmd = new MyAddressCommand(RootPanel.get("right_section"), info3k);
			cmd.execute();
		} else if(type.equals("myEvents")){
			MyEventCommand cmd = new MyEventCommand(RootPanel.get("right_section"), info3k);
			cmd.execute();
		} else if(type.equals("latestEvents")){
			EventCommand cmd = new EventCommand(RootPanel.get("right_section"), info3k, null);
			cmd.execute();
		}
	}
}
